package team.pra.manager.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import team.pra.manager.common.ManagerResult;
import team.pra.manager.common.PageHelper;
import team.pra.manager.mapper.RoomTypeMapper;
import team.pra.manager.pojo.RoomType;
import team.pra.manager.service.RoomTypeService;

import java.util.List;
@Service
public class RoomTypeServiceImpl implements RoomTypeService {
    @Autowired(required = false)
    private RoomTypeMapper roomTypeMapper;


    @Override
    public ManagerResult deleteRoomType(Integer id) {
        return ManagerResult.ok(roomTypeMapper.deleteRoomType(id));
    }

    @Override
    public ManagerResult updateRoomType(RoomType roomType) {
        return ManagerResult.ok(roomTypeMapper.updateRoomType(roomType));
    }

    @Override
    public ManagerResult insertRoomType(RoomType roomType) {
        return ManagerResult.ok(roomTypeMapper.insertRoomType(roomType));
    }
    //按条件获取房间类型
    @Override
    public void findRoomTypeByCondition(PageHelper<RoomType> pageHelper) {
        List<RoomType> roomTypes = roomTypeMapper.findRoomTypeByCondition(pageHelper);
        pageHelper.setData(roomTypes);
        pageHelper.setRecordsTotal(roomTypeMapper.countRoomType());
        pageHelper.setRecordsFiltered(roomTypeMapper.countFilterdRoomType(pageHelper));
    }

    @Override
    public List<RoomType> findAllRoomType() {
        return roomTypeMapper.findAllRoomType();
    }
}
